package cap3.ex6;

import javax.swing.JOptionPane;

public class AppCidade {
	public static void main(String args[]) {
		Cidade var1 = new Cidade(), var2 = new Cidade();
		double restoPrinc, totVerba, verbPop, verbReg, verbReg1 = 0, verbReg2 = 0, restoReg, verbPop1 = 0, verbPop2 = 0, restoPop;
		double totResto;

		var1.nome = JOptionPane.showInputDialog("Digite o nome:");
		var1.regiao = Integer.parseInt(JOptionPane
				.showInputDialog("Digite a regiao"));
		var1.populacao = Integer.parseInt(JOptionPane
				.showInputDialog("Digite a populacao"));

		var2.nome = JOptionPane.showInputDialog("Digite o nome:");
		var2.regiao = Integer.parseInt(JOptionPane
				.showInputDialog("Digite a regiao"));
		var2.populacao = Integer.parseInt(JOptionPane
				.showInputDialog("Digite a populacao"));

		totVerba = Double.parseDouble(JOptionPane
				.showInputDialog("Digite o total da verba:"));
		verbPop = totVerba / 2;
		verbReg = totVerba / 3;
		restoPrinc = (totVerba - (verbPop + verbReg)) / 2;

		if (var1.regiao == 1) {
			verbReg1 = verbReg * 0.1;
		} else if (var1.regiao == 2) {
			verbReg1 = verbReg * 0.2;
		} else if (var1.regiao == 3) {
			verbReg1 = verbReg * 0.3;
		} else if (var1.regiao == 4) {
			verbReg1 = verbReg * 0.4;
		} else if (var1.regiao == 5) {
			verbReg1 = verbReg * 0.5;
		}

		if (var2.regiao == 1) {
			verbReg2 = verbReg * 0.1;
		} else if (var2.regiao == 2) {
			verbReg2 = verbReg * 0.2;
		} else if (var2.regiao == 3) {
			verbReg2 = verbReg * 0.3;
		} else if (var2.regiao == 4) {
			verbReg2 = verbReg * 0.4;
		} else if (var2.regiao == 5) {
			verbReg2 = verbReg * 0.5;
		}

		restoReg = (verbReg - verbReg1 - verbReg2) / 2;

		if (var1.populacao < 10000) {
			verbPop1 = verbPop * 0.2;
		} else if (var1.populacao >= 10000) {
			verbPop1 = verbPop * 0.5;
		}

		if (var2.populacao < 10000) {
			verbPop2 = verbPop * 0.2;
		} else if (var2.populacao >= 10000) {
			verbPop2 = verbPop * 0.5;
		}

		restoPop = (verbPop - verbPop1 - verbPop2) / 2;

		totResto = restoPop + restoReg + restoPrinc;
		var1.totalVerba = verbPop1 + verbReg1 + totResto;
		var2.totalVerba = verbPop2 + verbReg2 + totResto;

		System.out.println(var1);
		System.out.println(var1.totalVerba);
		System.out.println(var2);
		System.out.println(var2.totalVerba);
	}
}
